#include "BLumberjack.h"

BLumberjack::BLumberjack(glm::vec3 _Pos, float _r, std::string _Name,
		std::string _modelFName, ModelPool *_mPool, PathFinder *_pathfinder) :
		Building(_Pos, _r, _Name, _modelFName, _mPool, _pathfinder)
{
	type = OBJ_BLUMBERJACK;
	parentType = OBJ_BUILDING;
}

BLumberjack::~BLumberjack(void)
{
}

void BLumberjack::control(float t)
{
	if (sleeping)
		return;

	if ((underConstruction) && timer.GetInterval(10))
		updateAge();

	if (slaves.size() > 0)
	{
		for (unsigned int i = 0; i < slaves.size(); i++)
		{
			if (slaves[i]->getType() == OBJ_GATHERER)
			{
				Gatherer *gat = static_cast<Gatherer*>(slaves[i]);
				if (gat->getStatus() == NOTHING)
				{
					void *ent = pathfinder->getNearestEntityOfType(gPoint, 20, OBJ_TREE);
					if (ent != NULL)
					{
						Tree *tree = static_cast<Tree*>(ent);
						gat->setWork(tree->get2dPosition(), gPoint);
					}
				}
			}
		}
	}

}